<template>
  <div>
    <input type="text"  name="content" v-model="content" v-if="flag" @change="changeflag" ref="dis"/>
    <button v-else @click="change">点击搜索</button>
  </div>
</template>

<script>
// dom.focus() 获取焦点
export default {
  data() {
    return {
      content:'',
      flag:false
    }
  },
  methods: {
    change(){
      this.flag=!this.flag
        this.$nextTick(()=>{
        this.$refs.dis.focus()
      })
    },
    changeflag(){
      console.log(this.content);
    
      this.flag=!this.flag
    }
  }
}
</script>

<style>
</style>